FROM jenkins:latest

MAINTAINER lijf <lijf@zts.com.cn>

USER root

# jdk and git have been installed in jenkins
RUN apt-get update && apt-get install -y wget  openssh-server && rm -rf /var/lib/apt/lists/*

# get maven 3.3.9
#RUN wget --no-verbose -O /tmp/apache-maven-3.3.9-bin.tar.gz http://mirrors.cnnic.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

# install maven
#RUN tar xzf /tmp/apache-maven-3.3.9-bin.tar.gz -C /opt/
#RUN ln -s /opt/apache-maven-3.3.9 /opt/maven
#RUN ln -s /opt/maven/bin/mvn /usr/local/bin
#RUN rm -f  /tmp/apache-maven-3.3.9-bin.tar.gz
#ENV MAVEN_HOME /opt/maven

#change the password of root
ARG rootpasswd=123456
RUN echo "root:$rootpasswd"|chpasswd

ENV JENKINS_HOME /usr/share/jenkins
ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org


RUN mkdir -p $JENKINS_HOME/plugins/ 
RUN chown -R jenkins:jenkins "$JENKINS_HOME"

RUN mkdir /var/run/sshd

EXPOSE 22 

USER jenkins
#install plugins
ARG  plugins="git ssh gitlab-plugin ssh-slaves timestamper ws-cleanup credentials-binding"
RUN for plugin in ${plugins} ; do \
        /usr/local/bin/install-plugins.sh $plugin ;done


#RUN groupadd -g 126 docker
#RUN addgroup -a jenkins docker

